package models

import com.jfinal.plugin.activerecord.Model

class CommentM: Model<CommentM>() {
    companion object {
        val AGENT by lazy {
            CommentM()
        }
        const val TABLE_NAME = "leave_msg"
        const val ID = "id"
        const val RECORD_ID = "record_id"
        const val USER_ID = "user_id"
        const val CREATE_TIME = "create_time"
        const val CONTENT = "content"
        const val EXTEND = "extend"

        fun findByRecordId(recordId: Int): List<CommentM>{
            return AGENT.find("select * from $TABLE_NAME where $RECORD_ID = ?", recordId)
        }

    }
}


class ReplyM: Model<ReplyM>(){
    companion object {
        val AGENT by lazy {
            ReplyM()
        }
        const val TABLE_NAME = "reply_msg"
        const val ID = "id"
        const val LV_MSG_ID = "lv_msg_id"
        const val CRATE_TIME = "create_time"
        const val FROM_USER_ID = "form_user_id"
        const val TO_USER_ID = "to_user_id"
        const val CONTENT = "content"
        const val EXTEND = "extend"

        fun findByCommentId(commentId: Int): List<ReplyM>{
            return AGENT.find("select * from $TABLE_NAME where $LV_MSG_ID = ?", commentId)
        }

    }
}